{%- extends "basic/layout.html" %}

{# Do this so that bootstrap is included before the main css file #}
{%- block htmltitle %}
  {% set script_files = script_files + ["_static/myscript.js"] %}
  <!-- Licensed under the Apache 2.0 License -->
  <link rel="stylesheet" type="text/css" href="{{ pathto('_static/fonts/open-sans/stylesheet.css', 1) }}" />
  <!-- Licensed under the SIL Open Font License -->
  <link rel="stylesheet" type="text/css" href="{{ pathto('_static/fonts/source-serif-pro/source-serif-pro.css', 1) }}" />
  <link href="https://fonts.googleapis.com/css?family=Noto+Serif" rel="stylesheet">
  <link rel="stylesheet" type="text/css" href="{{ pathto('_static/css/bootstrap.min.css', 1) }}" />
  <link rel="stylesheet" type="text/css" href="{{ pathto('_static/css/bootstrap-theme.min.css', 1) }}" />
  <link rel="stylesheet" type="text/css" href="{{ pathto('_static/css/nanoscroller.css', 1) }}" />
  <script defer src="https://use.fontawesome.com/releases/v5.0.2/js/all.js"></script>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script type="text/x-mathjax-config">
     MathJax.Hub.Config({
       "HTML-CSS": { scale: 90, linebreaks: { automatic: true } },
       TeX: {
         Macros: {
           pr : ['|\#1\\rangle\\langle\#1|',1],
           ket: ['\\left| \#1\\right\\rangle',1],
           bra: ['\\left\\langle \#1\\right|',1],
           xket: ['\\left| \#1\\right\\rangle_x',1],
           xbra: ['\\left\\langle \#1\\right|_x',1],
           braket: ['\\langle \#1 \\rangle',1],
           braketD: ['\\langle \#1 \\mid \#2 \\rangle',2],
           braketT: ['\\langle \#1 \\mid \#2 \\mid \#3 \\rangle',3],
           ketbra: ['| #1 \\rangle \\langle #2 |',2],
           hc: ['\\text{h.c.}',0],
           cc: ['\\text{c.c.}',0],
           h: ['\\hat',0],
           nn: ['\\nonumber',0],
           di: ['\\frac{d}{d \#1}',1],
           uu: ['\\mathcal{U}',0],
           inn: ['\\text{in}',0],
           out: ['\\text{out}',0],
           vac: ['\\text{vac}',0],
           I: ['\\hat{\\mathbf{1}}',0],
           x: ['\\hat{x}',0],
           p: ['\\hat{p}',0],
           a: ['\\hat{a}',0],
           ad: ['\\hat{a}^\\dagger',0],
           n: ['\\hat{n}',0],
           nbar: ['\\overline{n}',0],
           sech: ['\\mathrm{sech~}',0],
           tanh: ['\\mathrm{tanh~}',0],
           re: ['\\text{Re}',0],
           im: ['\\text{Im}',0],
           tr: ['\\mathrm{Tr} #1',1],
           sign: ['\\text{sign}',0],
           overlr: ['\\overset\\leftrightarrow{\#1}',1],
           overl: ['\\overset\leftarrow{\#1}',1],
           overr: ['\\overset\rightarrow{\#1}',1],
           avg: ['\\left< \#1 \\right>',1],
           slashed: ['\\cancel{\#1}',1],
           bold: ['\\boldsymbol{\#1}',1],
           d: ['\\mathrm d',0],
           expect: ["\\langle #1 \\rangle",1],
           pde: ["\\frac{\\partial}{\\partial \#1}",1],
           R: ["\\mathbb{R}",0],
           C: ["\\mathbb{C}",0],
           Ad: ["\\text{Ad}",0],
           Var: ["\\text{Var}",0],
           bx: ["\\mathbf{x}", 0],
           bm: ["\\boldsymbol{\#1}",1]
         }
       }
     });
     </script>

  {%- block ga %}
    {%- if theme_google_analytics_account %}
      <!-- Global site tag (gtag.js) - Google Analytics -->
      <script async src="https://www.googletagmanager.com/gtag/js?id={{ theme_google_analytics_account }}"></script>
      <script>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());

        gtag('config', '{{ theme_google_analytics_account }}');
      </script>
    {%- endif %}
  {%- endblock %}
  {{ super() }}
{%- endblock %}

{%- block extrahead %}
  {% if theme_touch_icon %}
  <link rel="apple-touch-icon" href="{{ pathto('_static/' ~ theme_touch_icon, 1) }}" />
  {% endif %}
  {{ super() }}
{% endblock %}

{# Displays the URL for the homepage if it's set or the master_doc if it is not #}
{% macro homepage() -%}
  {%- if theme_homepage %}
    {%- if hasdoc(theme_homepage) %}
      {{ pathto(theme_homepage) }}
    {%- else %}
      {{ theme_homepage }}
    {%- endif %}
  {%- else %}
    {{ pathto(master_doc) }}
  {%- endif %}
{%- endmacro %}

{# Displays the URL for the tospage if it's set or falls back to homepage macro #}
{% macro tospage() -%}
  {%- if theme_tospage %}
    {%- if hasdoc(theme_tospage) %}
      {{ pathto(theme_tospage) }}
    {%- else %}
      {{ theme_tospage }}
    {%- endif %}
  {%- else %}
    {{ homepage() }}
  {%- endif %}
{%- endmacro %}

{# Displays the URL for the projectpage if it's set or falls back to homepage macro #}
{% macro projectlink() -%}
  {%- if theme_projectlink %}
    {%- if hasdoc(theme_projectlink) %}
      {{ pathto(theme_projectlink) }}
    {%- else %}
      {{ theme_projectlink }}
    {%- endif %}
  {%- else %}
    {{ homepage() }}
  {%- endif %}
{%- endmacro %}

{# Displays the next and previous links both before and after content #}
{% macro render_relations() -%}
  {% if prev or next %}
  <div class="footer-relations">
    {% if prev %}
      <div class="pull-left">
        <a class="btn btn-xanadu" href="{{ prev.link|e }}" title="{{ _('previous chapter')}} (use the left arrow)"><i class="fas fa-arrow-left"></i> Previous</a>
      </div>
    {% endif %}
    {%- if next and next.title != '&lt;no title&gt;' %}
      <div class="pull-right">
        <a class="btn btn-xanadu" href="{{ next.link|e }}" title="{{ _('next chapter')}} (use the right arrow)">Next <i class="fas fa-arrow-right"></i></a>
      </div>
    {%- endif %}
    </div>
    <div class="clearer"></div>
  {% endif %}
{%- endmacro %}

{%- macro guzzle_sidebar() %}
  <div id="left-column" class="nano css-transitions-only-after-page-load">
    <div class="sphinxsidebar nano-content">
      {%- if sidebars != None %}
        {#- new style sidebar: explicitly include/exclude templates #}
        {%- for sidebartemplate in sidebars %}
        {%- include sidebartemplate %}
        {%- endfor %}
      {% else %}
        {% include "logo-text.html" %}
        {% include "searchbox.html" %}
        {% include "globaltoc.html" %}
      {%- endif %}
    </div>
  </div>
{%- endmacro %}

{%- block content %}

  {%- if pagename == 'index' and theme_index_template %}
    {% include theme_index_template %}
  {%- else %}
    <div class="container-wrapper">

      <div id="mobile-toggle">
        <a href="#"><span class="glyphicon glyphicon-align-justify" aria-hidden="true"></span></a>
      </div>

      {%- block sidebar1 %}{{ guzzle_sidebar() }}{% endblock %}

      {%- block document_wrapper %}
        {%- block document %}
        <div id="content">
          <div id="right-column">
            {% block breadcrumbs %}
            <div role="navigation" aria-label="breadcrumbs navigation">
              <ol class="breadcrumb">
                <li><a href="{{ pathto(master_doc) }}">Docs</a></li>
                {% for doc in parents %}
                  <li><a href="{{ doc.link|e }}">{{ doc.title }}</a></li>
                {% endfor %}
                <li>{{ title }}</li>
                {%- if show_source and has_source and sourcename %}
                  {%- if show_on_github_url %}
                    <li style="float: right;" class="showsource">
                      <a href="{{ show_on_github_url }}" class="reference-external" rel="nofollow">
                        <i class="fab fa-github"></i>
                        {{ _('Show on GitHub') }}
                      </a>
                    </li>
                  {%- endif %}
                  <li style="float: right;" class="showsource">
                    <a href="{{ pathto('_sources/' + sourcename, true)|e }}" class="reference-external" rel="nofollow">
                      {{ _('Show Source') }}
                    </a>
                  </li>
                {%- endif %}
              </ol>
            </div>
            {% endblock %}
            <div class="document clearer body">
              {% block body %} {% endblock %}
            </div>
            {%- block bottom_rel_links %}
              {{ render_relations() }}
            {%- endblock %}
          </div>
          {%- block comments -%}
            {% if theme_disqus_comments_shortname %}
            <div class="container comment-container">
              {% include "comments.html" %}
            </div>
            {% endif %}
          {%- endblock %}
          <div class="clearfix"></div>
        </div>
        {%- endblock %}
      {%- endblock %}


    </div>
  {%- endif %}
  {%- endblock %}

{%- block footer %}
<script type="text/javascript">
  $("#mobile-toggle a").click(function () {
    $("#left-column").toggle();
  });
</script>
<script type="text/javascript" src="{{ pathto('_static/js/bootstrap.js', 1)}}"></script>
<script type="text/javascript" src="{{ pathto('_static/js/nanoscroller.min.js', 1) }}"></script>
<script type="text/javascript">
    $(".nano").nanoScroller();
</script>
<script type="text/javascript">
    if ($('.current').length) {
        var target = $('.current')[0]
        var rect = target.getBoundingClientRect();
        if (rect.bottom > window.innerHeight) {
            $('.text-logo').addClass('active');
            $('.logo').removeClass('active');
            $('.logo-small').addClass('active');
            $(".nano").nanoScroller({ scrollTo: $('.current') });
        } else {
            $('.text-logo').addClass('active');
            $('.logo').removeClass('active');
            $('.logo-small').addClass('active');
            $(".nano").nanoScroller({ scrollTop: 93 });
        }
    }
    if ($('#search-documentation').length) {} else {
        $(".nano").on("update", function(event, values){
            $('.text-logo').toggleClass('active', $('.sphinxsidebar').scrollTop() > 0);
            var act = $('.text-logo').hasClass('active');
            if(act){
                $('.logo').removeClass('active');
                $('.logo-small').addClass('active');
            }
        });
    }
    $(".nano").bind("scrolltop", function(e){
        $('.logo-small').removeClass('active');
        $('.logo').addClass('active');
    });
    $(document).ready(function () {
        $(".css-transitions-only-after-page-load").each(function (index, element) {
            setTimeout(function () { $(element).removeClass("css-transitions-only-after-page-load") }, 10);
        });
    });
</script>
{%- block footer_wrapper %}
  <div class="footer">
    {{ copyright }} Documentation created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
  </div>
{%- endblock %}
{%- endblock %}
